package com.example.Controller;

import cn.dev33.satoken.util.SaResult;
import com.example.Service.impl.MenuImpl;
import com.example.Service.impl.RoleuImpl;
import com.example.entity.Module;
import com.example.entity.Role;
import com.example.entity.vo.MoudleVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {
    @Autowired
    RoleuImpl RoleuService;
    @PostMapping("/select")
    public SaResult select(@RequestBody Role role) {
        List<Role> roles = RoleuService.select(role);
        if (roles != null) {
            SaResult res = SaResult.data(roles);
            return res;
        }else {
            return SaResult.error("获取失败");
        }
    }

    @PostMapping("/insert")
    public SaResult insert(@RequestBody Role role) {
        int i= RoleuService.insert(role);
        if (i>0) {
            SaResult res = SaResult.ok("insert成功");
            return res;
        }else {
            return SaResult.error("insert失败");
        }
    }

    @PostMapping("/update")
    public SaResult update(@RequestBody Role role) {
        int i= RoleuService.update(role);
        if (i>0) {
            SaResult res = SaResult.ok("update成功");
            return res;
        }else {
            return SaResult.error("update失败");
        }
    }

    @PostMapping("/delete")
    public SaResult delete(@RequestBody Role role) {
        int i= RoleuService.delete(role);
        if (i>0) {
            SaResult res = SaResult.ok("delete成功");
            return res;
        }else {
            return SaResult.error("delete失败");
        }
    }
}
